<template>
	<rui-pages>
		<rui-chat @change="scrollToBottom"></rui-chat>
	</rui-pages>
</template>

<script setup>
	import {
		nextTick
	} from "vue"
	import {
		onLoad
	} from "@dcloudio/uni-app"

	import {
		apiGetBaseData
	} from "@/common/api.js"

	import {
		userStore
	} from "@/store/index.js"
	
	const user = userStore();

	onLoad(option => {
		if (option.p) {
			uni.setStorage({
				key: "PROMO",
				data: option.p
			})
		}
	})

	uni.$on('message', () => {
		scrollToBottom()
	})

	apiGetBaseData().then(res => {
		user.setBase(res.data)
		scrollToBottom();
	})

	const scrollToBottom = () => {
		nextTick(() => {
			uni.pageScrollTo({
				scrollTop: 20000000,
				duration: 0
			});
		});
	}
</script>

<style>

</style>